package simulate;

public class findPoisonedDuration {
    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int count=0;
        for(int i=0;i<timeSeries.length-1;i++){
            if(timeSeries[i+1]-duration>=timeSeries[i]){
                count+=duration;
            }else{
                count+=timeSeries[i+1]-timeSeries[i];
            }
        }
        count+=duration;
        return count;
    }
}
